﻿using System.Net;
using Letter.Net.Tcp;
using tcp_connection;

namespace tcp_server_test1;

class Program
{
    static async Task Main(string[] args)
    {
        var server = TcpProvider.Server();
        server.ConfigureChannelOptions(new TcpServerTransportOptions() { PooledSnder  = false});
        server.ConfigureFeatureOptions(new TcpServerFeatureOptions());
        server.ConfigureConnection(() =>
        {
            return new ServerTcpConnection();
        });
        server.Build();
        await server.BindAsync(IPEndPoint.Parse("0.0.0.0:20001"));
        
        Console.WriteLine(((IPEndPoint)server.BindEndPoint).Port);
        
        while (true)
        {
            string? str = Console.ReadLine();
            if (str == "c")
            {
                return;
            }

            if (str == "t")
            {
                Console.WriteLine("当前客户端连接数量：" + ServerStatistics.client_count);
            }
        }

        Console.ReadLine();
    }
}